package com.asman.vr.dto

import androidx.lifecycle.MutableLiveData
import androidx.paging.DataSource
import com.asman.vr.network.Api
import java.util.concurrent.Executor

class RecordDataSourceFactory(
        private val api: Api,
        private val projectId: Long,
        private val sort: Int,
        private val pageSize: Int,
        private val retryExecutor: Executor
) : DataSource.Factory<String, RecordListData>() {

    val sourceLiveData = MutableLiveData<RecordDataSource>()

    override fun create(): DataSource<String, RecordListData> {
        val source = RecordDataSource(api, projectId, sort, pageSize, retryExecutor)
        sourceLiveData.postValue(source)
        return source
    }
}
